package com.wl.application.controller;

import com.alibaba.nacos.api.exception.NacosException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author wl
 * @version 1.0
 * @date 2022/7/21
 * @description:
 */
@RestController
@RequestMapping("/provider")
public class ProviderController {

    @Value("${server.port}")
    public int port;
    @GetMapping("/hello")
    public String hello(String name,Integer age){

        return "name"+name+"age"+age+"hello["+port+"]"+System.currentTimeMillis();
    }

    @PostMapping("/save")
    public Map save(@RequestBody Map<String,Object>map){
        map.put("provider",port+"调用了远程api接口");
        return map;
    }
    @PostMapping("/del/{id}")
    public String del(@PathVariable Integer id) throws NacosException {
        return port+"调用了远程api接口，参数为："+id;
    }

    @GetMapping("/textTimeout")
    public String timeout() throws InterruptedException {
        System.out.println("开始执行了！");
        Thread.sleep(10000);
        System.out.println("结束执行了！");
        return "timeout";
    }
    @GetMapping("/serverText")
    public String serverText(){
        return "server服务二"+System.currentTimeMillis();
    }
}
